package com.bstek.service.impl;

import com.bstek.dao.CommunicationDao;
import com.bstek.model.domain.MisUser;
import com.bstek.service.CommunicationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.inject.Inject;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Transactional(rollbackFor = Exception.class)
@Service
public class CommunicationServiceImpl implements CommunicationService {

    @Inject
    CommunicationDao communicationDao;

    @Override
    public List<MisUser> getUsersByDeptId(Map<String, Object> params) {
        return communicationDao.getUsersByDeptId(params);
    }

    @Override
    public int count(Map<String, Object> map) {
        return communicationDao.count(map);
    }

    @Override
    public int saveMisUser(MisUser misUser) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        misUser.setId(uuid);
        return communicationDao.saveMisUser(misUser);
    }

    @Override
    public int updateMisUser(MisUser misUser) {
        return communicationDao.updateMisUser(misUser);
    }

    @Override
    public int delMisUserByIds(Map<String, List<String>> map) {
        List<String> ids = map.get("ids");
        return  communicationDao.delMisUserByIds(ids);
    }
}
